//
//  CJNativeRenderer.m
//  CJMobileAdapter
//
//  Created by ly on 2024/3/11.
//

#import "CJNativeRenderer.h"


@implementation CJNativeRenderer

- (void)renderOffer:(ATNativeADCache *)offer {
    [super renderOffer:offer];
    _customEvent = offer.assets[kATAdAssetsCustomEventKey];
    _customEvent.adView = self.ADView;
    self.ADView.customEvent = _customEvent;
    if ([offer.assets valueForKey:@"custom-platform-adInstance"]) {
        CJNativeAd *nativeAd = offer.assets[@"custom-platform-adInstance"];
        nativeAd.delegate = _customEvent;
    }
    UIView *feedView = offer.assets[kATAdAssetsCustomObjectKey];
    [self.ADView addSubview:feedView];
    CGRect frame = self.ADView.frame;
    frame.size.height = feedView.frame.size.height;
    frame.size.width = feedView.frame.size.width;
    self.ADView.frame = frame;
    feedView.center = CGPointMake(CGRectGetMidX(self.ADView.bounds), CGRectGetMidY(self.ADView.bounds));
}

@end
